stop_unloading_plugins
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Sun, 2 Jul 2017 23:07:11 +0000 (00:07 +0100)
committerLisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
Sun, 2 Jul 2017 23:07:11 +0000 (00:07 +0100)
Gbp-Pq: Name stop_unloading_plugins.diff

src/corelib/plugin/qfactoryloader.cpp
src/corelib/plugin/qpluginloader.cpp

index 6cd02e3a3fdfb56117524c6280f7928b74f9f172..13f7b89e2d0cf260f016b176a70d6be1c2cc9202 100644 (file)
@@ -187,10 +187,12 @@ void QFactoryLoader::update()
                     ++keyUsageCount;
                 }
             }
-            if (keyUsageCount || keys.isEmpty())
+            if (keyUsageCount || keys.isEmpty()) {
+                library->setLoadHints(QLibrary::PreventUnloadHint); // once loaded, don't unload
                 d->libraryList += library;
-            else
+            } else {
                 library->release();
+            }
         }
     }
 #else
index 094280e3b45cf22cf55cbb25edb54b8677f5534d..4ec4e43952b642dcb0fce5bfd816e82a116e7abd 100644 (file)
@@ -154,6 +154,7 @@ QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent)
     : QObject(parent), d(0), did_load(false)
 {
     setFileName(fileName);
+    setLoadHints(QLibrary::PreventUnloadHint);
 }
 
 /*!
@@ -348,7 +349,7 @@ static QString locatePlugin(const QString& fileName)
 void QPluginLoader::setFileName(const QString &fileName)
 {
 #if defined(QT_SHARED)
-    QLibrary::LoadHints lh;
+    QLibrary::LoadHints lh = QLibrary::PreventUnloadHint;
     if (d) {
         lh = d->loadHints();
         d->release();
@@ -394,7 +395,7 @@ QString QPluginLoader::errorString() const
     \brief Give the load() function some hints on how it should behave.
 
     You can give hints on how the symbols in the plugin are
-    resolved. By default, none of the hints are set.
+    resolved. By default since Qt 5.7, QLibrary::PreventUnloadHint is set.
 
     See the documentation of QLibrary::loadHints for a complete
     description of how this property works.